package com.hb.config.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/config")
@RefreshScope // 用于实现热插拔和动态刷新配置
public class ConfigController {
    @Value("${city.address}") // 获取的事 appliaction.yml 中 的配置
    public String address;

    @Value("${user.name}")  // 获取的是  nacos中的配置
    public String username;

    @RequestMapping("/show")
    public String show(){
        System.out.println("address = " + address);
        System.out.println("username = " + username);
        return username;
    }
}
